﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using InspectionDAL;
using InspectionVehicule.Controleur;
using InspectionVehicule.WorkflowHost;
using InspectionPageFlow;

namespace InspectionVehicule
{
    public partial class _Default : System.Web.UI.Page
    {
        private const string COMMANDE_SELECT = "Select";

        protected void Page_Load(object sender, EventArgs e)
        {
            
        }

        protected void btnNouveau_Click(object sender, EventArgs e)
        {
            HttpContext.Current.Response.Redirect("CreationInspection.aspx");
        }

        protected void grdListeInspectionEnCours_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == COMMANDE_SELECT)
            {
                int indexLigne = Int32.Parse(e.CommandArgument.ToString());
                Guid idWorkflow = Guid.Parse(grdListeInspectionEnCours.DataKeys[indexLigne].Value.ToString());

                InspectionWorkflowHost hote = new InspectionWorkflowHost();
                hote.WorkflowId = idWorkflow;

                string urlPage = hote.RouterPage(null, null, NavigationAction.Resume);
                Session["PageState"] = hote.Donnees;
                Session["WorkflowId"] = idWorkflow;
                Response.Redirect(urlPage);
            }
        }

        
    }
}